<template>
    <div class="page_root" :key="queryUpdateFlag" data-page-name="项目子目标" data-page-identification="u_87z6vsr0m9">
        <a-spin :spinning="pageLoading.loading" :tip="pageLoading.tip">
            <!-- begin vid_v3oimkn2cs 自定义模板_k0p6v9ccmr -->
            <!--          查看任务-->
            <a-modal
                width="100vw"
                v-model:visible="taskMoadlVisible"
                :mask-closable="false"
                :keyboard="false"
                centered
                destroy-on-close
                :footer="null"
            >
                <TaskJump :storyId="taskModalId" />
            </a-modal>
            <!--          查看任务-->
            <!--          新建/编辑年度目标-->
            <a-modal
                v-model:visible="targetState.addOrEditYearGoalVisible"
                :title="targetState.yearGoalTitle"
                @ok="handleSubmitYearGoal"
                @cancel="resetYearGoal"
                :mask-closable="false"
                :keyboard="false"
                centered
                destroy-on-close
                :ok-button-props="{ loading: targetState.addOrEditYearGoalLoading }"
            >
                <a-form :model="targetState.yearGoalModalForm" ref="yearGoalRef">
                    <a-row>
                        <a-col :span="24">
                            <a-form-item
                                label="目标年份"
                                name="year"
                                :rules="[{ required: true, message: '请选择目标年份', trigger: 'blur' }]"
                            >
                                <a-date-picker
                                    style="width: 100%"
                                    picker="year"
                                    value-format="YYYY"
                                    v-model:value="targetState.yearGoalModalForm.year"
                                />
                            </a-form-item>
                        </a-col>
                        <a-col :span="24">
                            <a-form-item
                                label="年度目标"
                                name="goal"
                                :rules="[{ required: true, message: '请输入年度目标', trigger: 'blur' }]"
                            >
                                <a-textarea
                                    v-model:value="targetState.yearGoalModalForm.goal"
                                    :placeholder="inputHolder"
                                    :rows="4"
                                />
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-form>
            </a-modal>
            <!--          新建/编辑年度目标-->
            <!--          范围查看-->
            <a-modal
                v-model:visible="targetState.showScopeVisible"
                title="范围查看"
                :footer="null"
                :mask-closable="false"
                :keyboard="false"
                centered
                width="100%"
            >
                <a-row :gutter="16">
                    <a-col :span="5">
                        <a-form-item :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }" label="年份">
                            <a-date-picker
                                style="width: 100%"
                                v-model:value="targetState.scopeFilter.year"
                                picker="year"
                                :allow-clear="false"
                                value-format="YYYY"
                                @change="
                                    () => {
                                        handleScopeYearChange()
                                    }
                                "
                            />
                        </a-form-item>
                    </a-col>
                    <a-col :span="5">
                        <a-form-item :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" label="月份筛选">
                            <a-range-picker
                                style="width: 100%"
                                v-model:value="targetState.scopeFilter.month"
                                picker="month"
                                value-format="YYYY-MM"
                                :allow-clear="false"
                                @change="getScopeData"
                                :disabled-date="scopeDisabledMonth"
                            />
                        </a-form-item>
                    </a-col>
                    <a-col :span="4">
                        <a-button ghost type="primary" @click="resetScope">重置</a-button>
                    </a-col>
                </a-row>
                <div class="table-box">
                    <a-table
                        :columns="targetState.scopeColumns"
                        :data-source="targetState.scopeData"
                        bordered
                        :loading="targetState.scopeLoading"
                        :scroll="{ x: 1000, y: 600 }"
                        :pagination="false"
                    >
                        <template #bodyCell="{ column, record }">
                            <!-- 左侧字段列：直接显示，不做特殊处理 -->
                            <template v-if="column.dataIndex === 'field'">
                                {{ record.field }}
                            </template>

                            <!-- 子目标：逐条渲染 -->
                            <template v-else-if="record.field === '子目标'">
                                <div
                                    v-for="(goal, i) in record[column.dataIndex]"
                                    :key="i"
                                    style="
                                        margin-bottom: 6px;
                                        padding-left: 6px;
                                        border-left: 3px solid #1677ff;
                                        white-space: pre-line;
                                    "
                                >
                                    <strong>{{ goal.idx }}.</strong> {{ goal.text }}
                                </div>
                            </template>

                            <!-- 月度总目标：保留换行符 -->
                            <template v-else-if="record.field === '月度总目标'">
                                <div style="white-space: pre-line; text-align: left">
                                    {{ record[column.dataIndex] }}
                                </div>
                            </template>

                            <!-- 默认展示 -->
                            <template v-else>
                                {{ record[column.dataIndex] }}
                            </template>
                        </template>
                    </a-table>
                </div>
            </a-modal>
            <!--          范围查看-->
            <!--            甘特图-->
            <a-modal
                :visible="targetState.ganteVisible"
                title="目标甘特图"
                :footer="null"
                centered
                @cancel="cancelGante"
                width="100%"
                :body-style="{
                    maxHeight: '800px',
                    overflowY: 'auto'
                }"
            >
                <Gante v-if="targetState.ganteVisible" :time="gantMonth" :projectName="gantProjectName" />
            </a-modal>
            <!--            甘特图-->
            <!--            查看问题-->
            <a-modal
                :visible="showMsgState.visible"
                title="用户故事描述"
                :footer="null"
                centered
                @cancel="cancelShowMsg"
                width="1000px"
                :body-style="{
                    maxHeight: '800px',
                    overflowY: 'auto'
                }"
            >
                <div class="item-content" v-html="getHtmlContent(showMsgState.msg)"> </div>
            </a-modal>
            <!--            查看问题-->
            <!--            新建/编辑用户故事-->
            <a-modal
                :visible="milepostState.addOrEditVisible"
                :title="milepostState.addOrEditTitle"
                centered
                :mask-closable="false"
                destroy-on-close
                :body-style="{
                    maxHeight: '800px',
                    overflowY: 'auto'
                }"
                width="1000px"
                @cancel="cancelStory"
            >
                <template #footer>
                    <a-button type="primary" @click="cancleMbTask"> 取消</a-button>
                    <a-button
                        type="primary"
                        v-if="
                            milepostState.current == 1 &&
                            milepostState.modalForm.templateTaskId?.length > 0 &&
                            !currentData.id
                        "
                        @click="getTask"
                        :loading="milepostState.nextLoading"
                    >
                        下一步</a-button
                    >
                    <a-button type="primary" v-if="milepostState.current == 2" @click="milepostState.current = 1">
                        上一步</a-button
                    >
                    <a-button
                        type="primary"
                        @click="confirmMbTask"
                        v-if="
                            milepostState.current == 2 ||
                            (milepostState.modalForm.templateTaskId?.length == 0 && milepostState.current == 1)
                        "
                        :loading="milepostState.okLoading"
                    >
                        确定</a-button
                    >
                </template>
                <div class="form-model">
                    <a-form :model="milepostState.modalForm" ref="formRef" :rules="rules">
                        <a-row v-if="milepostState.current == 1">
                            <a-col :span="12">
                                <a-form-item label="月份">
                                    <a-date-picker
                                        v-model:value="milepostState.modalForm.monthlyGoalTargetMonth"
                                        value-format="YYYY-MM"
                                        picker="month"
                                        style="width: 100%"
                                        @change="milepostState.modalForm.projectMonthlyGoalManagementId = undefined"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item label="月度子目标">
                                    <a-select
                                        :options="milepostState.targetList"
                                        v-model:value="milepostState.modalForm.projectMonthlyGoalManagementId"
                                        show-search
                                        :filterOption="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                        :placeholder="selectHolder"
                                        allow-clear
                                        @focus="getTarget"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item label="版本号" name="iterationVersionId">
                                    <a-select
                                        v-model:value="milepostState.modalForm.iterationVersionId"
                                        placeholder="请选择"
                                        allowClear
                                        :options="targetState.versionList"
                                        show-search
                                        :filter-option="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                        @focus="getAllVersion"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item label="负责人" name="ownerList">
                                    <a-select
                                        v-model:value="milepostState.modalForm.ownerList"
                                        placeholder="请选择"
                                        allowClear
                                        mode="multiple"
                                        :options="peopleList"
                                        show-search
                                        :filter-option="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                        @focus="getAllUser"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24">
                                <a-form-item label="用户故事名称" name="storyName">
                                    <a-input
                                        v-model:value="milepostState.modalForm.storyName"
                                        :placeholder="inputHolder"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item label="计划起止时间">
                                    <a-range-picker
                                        style="width: 100%"
                                        v-model:value="milepostState.modalForm.timeRangeList"
                                        valueFormat="YYYY-MM-DD"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item
                                    label="优先级"
                                    name="priority"
                                    :rules="[{ required: true, msssage: '请选择优先级', trigger: 'blur' }]"
                                >
                                    <a-select
                                        :options="[
                                            {
                                                label: 'P0',
                                                value: 'P0'
                                            },
                                            {
                                                label: 'P1',
                                                value: 'P1'
                                            },
                                            {
                                                label: 'P2',
                                                value: 'P2'
                                            },
                                            {
                                                label: 'P3',
                                                value: 'P3'
                                            }
                                        ]"
                                        :placeholder="selectHolder"
                                        v-model:value="milepostState.modalForm.priority"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24">
                                <a-form-item label="描述" name="labels">
                                    <QuillEditor
                                        v-model:content="milepostState.modalForm.description"
                                        ref="quillEditor"
                                        :options="editorOption"
                                        class="quill-editor"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24">
                                <a-form-item label="标签" name="labels">
                                    <a-input
                                        v-model:value="milepostState.modalForm.labels"
                                        show-count
                                        :placeholder="inputHolder"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24" v-if="!currentData.id">
                                <a-form-item
                                    label="功能简称"
                                    name="functionAbbreviation"
                                    :rules="[
                                        {
                                            required: milepostState.modalForm.templateTaskId.length > 0 ? true : false,
                                            message: '请输入功能简称',
                                            trigger: 'blur'
                                        }
                                    ]"
                                >
                                    <a-input
                                        :placeholder="inputHolder"
                                        v-model:value="milepostState.modalForm.functionAbbreviation"
                                        maxlength="10"
                                        show-count
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24" v-if="!currentData.id">
                                <a-form-item label="SOP任务">
                                    <a-tree-select
                                        v-model:value="milepostState.modalForm.templateTaskId"
                                        show-search
                                        multiple
                                        treeCheckable
                                        style="width: 100%"
                                        placeholder="请选择"
                                        allow-clear
                                        treeDefaultExpandAll
                                        :tree-data="milepostState.treeData"
                                        :fieldNames="{
                                            children: 'children',
                                            label: 'taskName',
                                            value: 'taskId',
                                            key: 'taskId'
                                        }"
                                        :filterTreeNode="
                                            (inputValue, treeNode) => {
                                                return (
                                                    treeNode.taskName.toLowerCase().indexOf(inputValue.toLowerCase()) >=
                                                    0
                                                )
                                            }
                                        "
                                        :max-tag-count="7"
                                        @focus="getTreeData"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="24">
                                <a-form-item label="备注">
                                    <a-textarea v-model:value="milepostState.modalForm.remarks" />
                                </a-form-item>
                            </a-col>
                        </a-row>
                        <div v-else>
                            <div
                                v-for="(item, index) in milepostState.modalForm.taskList"
                                :key="index"
                                class="form-item"
                            >
                                <div class="form-content">
                                    <a-row class="one-line">
                                        <a-col :span="24">
                                            <a-form-item
                                                label="任务名称"
                                                :name="['taskList', index, 'taskName']"
                                                :rules="[
                                                    {
                                                        required: true,
                                                        message: '请输入任务名称!'
                                                    },
                                                    {
                                                        validator: () => {
                                                            if (milepostState.modalForm.taskList[index].taskName) {
                                                                if (
                                                                    milepostState.modalForm.taskList[
                                                                        index
                                                                    ].taskName.trim()
                                                                ) {
                                                                    return PromiseProxy.resolve()
                                                                } else {
                                                                    return PromiseProxy.reject('请输入任务名称!')
                                                                }
                                                            } else {
                                                                return PromiseProxy.resolve()
                                                            }
                                                        }
                                                    }
                                                ]"
                                            >
                                                <a-input
                                                    disabled
                                                    :placeholder="inputHolder"
                                                    v-model:value="milepostState.modalForm.taskList[index].taskName"
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>

                                    <a-row>
                                        <a-col :span="12">
                                            <a-form-item
                                                label="预计投入工时"
                                                :name="['taskList', index, 'workingHours']"
                                                :rules="[
                                                    { required: true, message: '请输入预计投入工时!', trigger: 'blur' },
                                                    {
                                                        pattern: /^(0\.5|[1-9](\d*)?(\.5)?(\.0)?)$/,
                                                        message: '请输入大于0的数字(支持0.5的倍数)',
                                                        trigger: 'blur'
                                                    }
                                                ]"
                                            >
                                                <a-input
                                                    placeholder="请输入工时(支持0.5的数字)"
                                                    v-model:value="milepostState.modalForm.taskList[index].workingHours"
                                                    :min="0"
                                                    type="number"
                                                    suffix="小时"
                                                />
                                            </a-form-item>
                                        </a-col>
                                        <a-col :span="12">
                                            <a-form-item
                                                label="任务起止时间"
                                                :name="['taskList', index, 'allTime']"
                                                :rules="{ required: true, message: '请选择任务起止时间!' }"
                                            >
                                                <a-range-picker
                                                    style="width: 100%"
                                                    v-model:value="milepostState.modalForm.taskList[index].allTime"
                                                    valueFormat="YYYY-MM-DD"
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                    <a-row>
                                        <a-col :span="12">
                                            <a-form-item
                                                label="任务负责人"
                                                :name="['taskList', index, 'taskOwner']"
                                                :rules="{ required: true, message: '请选择任务负责人!' }"
                                            >
                                                <a-select
                                                    :placeholder="selectHolder"
                                                    v-model:value="milepostState.modalForm.taskList[index].taskOwner"
                                                    showSearch
                                                    :options="peopleList"
                                                    :field-names="{ label: 'label', value: 'value' }"
                                                    :filter-option="
                                                        (input, option) => {
                                                            return (
                                                                option.label
                                                                    .toLowerCase()
                                                                    .indexOf(input.toLowerCase()) >= 0
                                                            )
                                                        }
                                                    "
                                                />
                                            </a-form-item>
                                        </a-col>
                                        <a-col :span="12">
                                            <a-form-item
                                                label="审核员"
                                                :name="['taskList', index, 'assessorName']"
                                                :rules="{ required: true, message: '请选择审核员!' }"
                                            >
                                                <a-select
                                                    :placeholder="selectHolder"
                                                    v-model:value="milepostState.modalForm.taskList[index].assessorName"
                                                    showSearch
                                                    :options="peopleList"
                                                    :field-names="{ label: 'label', value: 'value' }"
                                                    :filter-option="
                                                        (input, option) => {
                                                            return (
                                                                option.label
                                                                    .toLowerCase()
                                                                    .indexOf(input.toLowerCase()) >= 0
                                                            )
                                                        }
                                                    "
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                    <a-row class="one-line">
                                        <a-col :span="24">
                                            <a-form-item
                                                label="任务执行人"
                                                :name="['taskList', index, 'taskParticipantList']"
                                                :rules="{ required: true, message: '请选择任务参与人!' }"
                                            >
                                                <a-select
                                                    :placeholder="selectHolder"
                                                    v-model:value="
                                                        milepostState.modalForm.taskList[index].taskParticipantList
                                                    "
                                                    showSearch
                                                    mode="multiple"
                                                    :options="peopleList"
                                                    :field-names="{ label: 'label', value: 'value' }"
                                                    :filter-option="
                                                        (input, option) => {
                                                            return (
                                                                option.label
                                                                    .toLowerCase()
                                                                    .indexOf(input.toLowerCase()) >= 0
                                                            )
                                                        }
                                                    "
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                    <a-row>
                                        <a-col v-if="taskPeopleList.length > 0">
                                            <div style="width: 600px; margin-left: 115px; margin-bottom: 28px">
                                                <a
                                                    href="javascript:;"
                                                    v-for="(item, num) in taskPeopleList"
                                                    @click="handlerAddPtMbPeople(item.value, index)"
                                                    ><span style="margin: 0 5px">{{ item.value }}</span></a
                                                >
                                            </div>
                                        </a-col>
                                    </a-row>
                                    <a-row class="one-line">
                                        <a-col :span="24">
                                            <a-form-item label="备注">
                                                <a-textarea
                                                    v-model:value="milepostState.modalForm.taskList[index].remark"
                                                    :placeholder="inputHolder"
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </div>
                        </div>
                    </a-form>
                </div>
            </a-modal>
            <!--            新建/编辑用户故事-->
            <!--        新建/编辑月度目标    -->
            <a-modal
                :visible="targetState.addOrEditVisible"
                :title="targetState.addOrEditTitle"
                centered
                width="800px"
                :body-style="{
                    maxHeight: '800px',
                    overflowY: 'auto'
                }"
                destroy-on-close
                @ok="submitTarget"
                @cancel="cancelTarget"
                :mask-closable="false"
                :ok-button-props="{ loading: targetState.targetLoadog }"
            >
                <div class="modal-form">
                    <a-form :model="targetState.modalForm" ref="targetFormRef">
                        <a-row>
                            <a-col :span="11">
                                <a-form-item
                                    label="目标月份"
                                    :rules="[{ required: true, message: '请选择目标月份', trigger: 'blur' }]"
                                    name="targetMonth"
                                >
                                    <a-date-picker
                                        :disabled="currentEditData.overallProjectId"
                                        style="width: 100%"
                                        picker="month"
                                        v-model:value="targetState.modalForm.targetMonth"
                                        value-format="YYYY-MM"
                                        @change="getLastPeople"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="11" />
                            <a-divider style="margin-bottom: 16px; margin-top: 0" />
                            <a-col :span="22">
                                <a-form-item
                                    label="项目总目标"
                                    :rules="[{ required: true, message: '请输入项目总目标', trigger: 'blur' }]"
                                    name="totalMonthlyGoal"
                                >
                                    <a-textarea
                                        v-model:value="targetState.modalForm.totalMonthlyGoal"
                                        :placeholder="inputHolder"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="11">
                                <a-form-item
                                    label="团队负责人"
                                    :rules="[{ required: true, message: '请选择团队负责人', trigger: 'blur' }]"
                                    name="teamLeaderList"
                                >
                                    <a-select
                                        show-search
                                        mode="multiple"
                                        :options="targetState.allUser"
                                        v-model:value="targetState.modalForm.teamLeaderList"
                                        :filterOption="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                        :placeholder="selectHolder"
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="11">
                                <a-form-item
                                    label="负责人"
                                    :rules="[{ required: true, message: '请选择负责人', trigger: 'blur' }]"
                                    name="leaderList"
                                >
                                    <a-select
                                        show-search
                                        :placeholder="selectHolder"
                                        mode="multiple"
                                        :options="targetState.allUser"
                                        v-model:value="targetState.modalForm.leaderList"
                                        :filterOption="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col :span="22">
                                <a-form-item
                                    label="团队成员"
                                    :rules="[{ required: true, message: '请选择团队成员', trigger: 'blur' }]"
                                    name="participantsList"
                                >
                                    <a-select
                                        :placeholder="selectHolder"
                                        show-search
                                        mode="multiple"
                                        :options="targetState.allUser"
                                        v-model:value="targetState.modalForm.participantsList"
                                        :filterOption="
                                            (input, option) => {
                                                return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                            }
                                        "
                                    />
                                </a-form-item>
                            </a-col>
                            <a-col v-if="lastPeopleList.length > 0" :span="22">
                                <div style="width: 600px; margin-left: 100px; margin-bottom: 28px">
                                    <a
                                        href="javascript:;"
                                        v-for="(people, num) in lastPeopleList"
                                        @click="handlerAddLastPeople(people.value)"
                                        ><span style="margin: 0 5px">{{ people.value }}</span></a
                                    >
                                </div>
                            </a-col>
                            <a-col :span="24">
                                <div v-for="(item, index) in targetState.modalForm.monthlyGoalObjectList" :key="index">
                                    <a-row>
                                        <a-col :span="22">
                                            <a-form-item
                                                label="子目标"
                                                :rules="[{ required: true, message: '请输入子目标', trigger: 'blur' }]"
                                                :name="['monthlyGoalObjectList', index, 'monthlyGoal']"
                                            >
                                                <a-textarea
                                                    v-model:value="
                                                        targetState.modalForm.monthlyGoalObjectList[index].monthlyGoal
                                                    "
                                                    :placeholder="inputHolder"
                                                />
                                            </a-form-item>
                                        </a-col>
                                        <a-col :span="2">
                                            <a-button @click="handleDeleteTargetItem(index)" type="link">删除</a-button>
                                        </a-col>
                                        <a-col :span="22">
                                            <a-form-item
                                                label="验收标准"
                                                :rules="[
                                                    { required: true, message: '请输入验收标准', trigger: 'blur' }
                                                ]"
                                                :name="['monthlyGoalObjectList', index, 'acceptanceCriteria']"
                                            >
                                                <a-textarea
                                                    v-model:value="
                                                        targetState.modalForm.monthlyGoalObjectList[index]
                                                            .acceptanceCriteria
                                                    "
                                                    :placeholder="inputHolder"
                                                />
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                </div>
                            </a-col>
                            <a-col :span="22">
                                <a-button @click="handleAddTargetItem" type="primary" ghost
                                    ><template #icon><plus-outlined /></template> 新增</a-button
                                >
                            </a-col>
                        </a-row>
                    </a-form>
                </div>
            </a-modal>
            <!--        新建/编辑月度目标    -->
            <div class="body">
                <div class="top-search">
                    <a-row>
                        <a-col :span="18">
                            <a-row :gutter="16">
                                <a-col :span="8">
                                    <a-form-item :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }" label="年份">
                                        <a-date-picker
                                            style="width: 100%"
                                            v-model:value="targetState.searchForm.year"
                                            picker="year"
                                            value-format="YYYY"
                                            :allow-clear="false"
                                            @change="
                                                () => {
                                                    handleYearChange()
                                                }
                                            "
                                        />
                                    </a-form-item>
                                </a-col>
                                <a-col :span="8">
                                    <a-form-item :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" label="月份筛选">
                                        <a-range-picker
                                            style="width: 100%"
                                            v-model:value="targetState.searchForm.month"
                                            picker="month"
                                            value-format="YYYY-MM"
                                            :allow-clear="false"
                                            @change="getData"
                                            :disabled-date="topSearchDisabledMonth"
                                        />
                                    </a-form-item>
                                </a-col>
                                <a-col :span="1">
                                    <a-button @click="resetData" type="primary" ghost> 重置</a-button>
                                </a-col>
                            </a-row>
                        </a-col>
                        <a-col
                            :span="6"
                            style="display: flex; flex-direction: row; justify-content: flex-end; align-items: start"
                        >
                            <a-space>
                                <a-button @click="handleExpendAll" type="primary" ghost>{{
                                    allExpanded ? '全部收起' : '全部展开'
                                }}</a-button>
                                <a-button
                                    @click="handleAddTarget"
                                    v-permission="'3000001092_vid_ldj2jyl9u6'"
                                    type="primary"
                                >
                                    新建月度目标</a-button
                                >
                                <a-button
                                    @click="handleShowScope"
                                    v-permission="'3000001092_vid_d6ulsmurt1'"
                                    type="primary"
                                >
                                    范围查看</a-button
                                >
                            </a-space>
                        </a-col>
                    </a-row>
                </div>
                <div class="year-goal-content" ref="goalContentRef">
                    <div class="year-goal-title">
                        <div class="year-font">年度目标</div>
                        <a-space>
                            <div style="margin-right: 8px"
                                ><span class="label">创建时间:</span>
                                <span class="value">{{ targetState.yearGoal[0]?.updateTime }}</span>
                            </div>
                            <div style="margin-right: 8px"
                                ><span class="label">创建人:</span>
                                <span class="value">{{ targetState.yearGoal[0]?.updateBy }}</span>
                            </div>
                            <a-button
                                type="primary"
                                size="small"
                                v-permission="'3000001092_vid_iz6lzo6o40'"
                                ghost
                                @click="showAddOrEditYearGoal"
                                >{{ targetState.yearGoal.length > 0 ? '编辑年度目标' : '新建年度目标' }}</a-button
                            >
                            <a-popconfirm
                                title="确定删除吗?"
                                ok-text="确定"
                                cancel-text="取消"
                                @confirm="handleDeleteYearGoal"
                                @cancel="cancel"
                            >
                                <a-button :disabled="!targetState.yearGoal[0]" type="primary" size="small" ghost
                                    >删除</a-button
                                >
                            </a-popconfirm>
                        </a-space>
                    </div>
                    <a-descriptions bordered size="small" :label-style="{ width: '100px', backgroundColor: '#f2f6fc' }">
                        <a-descriptions-item label="年度目标">
                            <a-tooltip>
                                <template #title>
                                    <span
                                        style="
                                            white-space: pre-wrap; /* 保留后端返回的换行符 */
                                            word-break: break-word; /* 单词过长自动换行 */
                                        "
                                    >
                                        {{ targetState.yearGoal[0].yearGoals }}</span
                                    >
                                </template>
                                <div class="desc-value" v-if="targetState.yearGoal.length > 0">
                                    {{ targetState.yearGoal[0].yearGoals }}
                                </div>
                            </a-tooltip>
                        </a-descriptions-item>
                    </a-descriptions>
                </div>
                <a-spin :spinning="targetState.loading" tip="加载中">
                    <div class="content" :style="{ height: contentHeight + 'px' }">
                        <div class="no-data-image" v-if="targetState.dataSource.length == 0">
                            <div class="no-date-tip"> 暂无数据 </div>
                        </div>
                        <div v-for="goal in targetState.dataSource" :key="goal.id" class="goal-card">
                            <div class="goal-title-bar">
                                <div class="goal-info">
                                    <div class="goal-month ft16">{{ goal.targetMonth }}</div>
                                    <div class="goal-product-jf" v-if="goal.projectType === '交付'">{{
                                        goal.projectType
                                    }}</div>
                                    <div class="goal-product-cp" v-if="goal.projectType === '产品研发'">{{
                                        goal.projectType
                                    }}</div>
                                    <div class="goal-product-sc" v-if="goal.projectType === '市场'">{{
                                        goal.projectType
                                    }}</div>
                                    <div class="goal-name" :title="goal.projectName">{{ goal.projectName }}</div>
                                </div>
                                <div class="goal-ops">
                                    <div class="approve-img"></div>
                                    <div>
                                        <span class="ft-label">审批状态：</span>
                                        <span class="ft14">{{ goal.approvalStatus }}</span>
                                    </div>
                                    <div class="time-img"></div>
                                    <div>
                                        <span class="ft-label">提交时间：</span>
                                        <span class="ft14">{{ goal.modifiedTime }}</span>
                                    </div>
                                    <!--                                    confirmHiddenGoal-->
                                    <a-popconfirm
                                        placement="left"
                                        title="请确认在该项目中是否取消展示该月度目标?"
                                        ok-text="确定"
                                        cancel-text="取消"
                                        @confirm="confirmHiddenGoal(goal)"
                                        @cancel="cancel"
                                    >
                                        <a-button
                                            type="link"
                                            v-permission="'3000001092_vid_ssz015yzl8'"
                                            size="small"
                                            class="btn-no-margin"
                                            >取消展示</a-button
                                        >
                                    </a-popconfirm>
                                    <a-divider
                                        v-permission="'3000001092_vid_ssz015yzl8'"
                                        type="vertical"
                                        style="background-color: #3875ff; margin: 0"
                                    />
                                    <a-button
                                        type="link"
                                        size="small"
                                        class="btn-no-margin"
                                        @click="showGante(goal)"
                                        v-permission="'3000001092_vid_cdcz5cg9hu'"
                                        >甘特图</a-button
                                    >
                                    <a-divider
                                        v-permission="'3000001092_vid_cdcz5cg9hu'"
                                        type="vertical"
                                        style="background-color: #3875ff; margin: 0"
                                    />
                                    <a-button
                                        type="link"
                                        size="small"
                                        class="btn-no-margin"
                                        @click="handleEditGoal(goal)"
                                        v-permission="'3000001092_vid_41qr3p2kzn'"
                                        >编辑</a-button
                                    >
                                    <a-divider
                                        v-permission="'3000001092_vid_41qr3p2kzn'"
                                        type="vertical"
                                        style="background-color: #3875ff; margin: 0"
                                    />
                                    <a-popconfirm
                                        placement="left"
                                        title="确定删除吗?"
                                        ok-text="确定"
                                        cancel-text="取消"
                                        @confirm="confirmDeleteGoal(goal)"
                                        @cancel="cancel"
                                    >
                                        <a-button
                                            v-permission="'3000001092_vid_95rq6cceha'"
                                            type="link"
                                            size="small"
                                            class="btn-no-margin"
                                            >删除</a-button
                                        >
                                    </a-popconfirm>
                                </div>
                            </div>
                            <div class="first-line">
                                <div class="line-item">
                                    <div class="xs-img"></div>
                                    <span class="ft-label">完成系数：</span>
                                    <span class="ft14" :title="goal.finishCoefficient">{{
                                        goal.finishCoefficient
                                    }}</span>
                                </div>
                                <div class="line-item">
                                    <div class="trd-img"></div>
                                    <span class="ft-label">投入度总数：</span>
                                    <span class="ft14" :title="goal.investment">{{ goal.investment }}</span>
                                </div>
                                <div class="line-item">
                                    <div class="tl-img"></div>
                                    <span class="ft-label">团队负责人：</span>
                                    <span class="ft14" :title="goal.teamLeader">{{ goal.teamLeader }}</span>
                                </div>
                                <div class="line-item">
                                    <div class="fzr-img"></div>
                                    <span class="ft-label">负责人：</span>
                                    <span class="ft14" :title="goal.leader">{{ goal.leader }}</span>
                                </div>
                            </div>
                            <div class="first-line">
                                <div class="line-item">
                                    <div class="fzr-img"></div>
                                    <span class="ft-label">团队成员：</span>
                                    <span class="ft14" :title="goal.participants">{{ goal.participants }}</span>
                                </div>
                            </div>
                            <div class="second-line">
                                <div class="line-item">
                                    <div class="zmb-img"></div>
                                    <span class="ft-label">月度总目标：</span>
                                    <span class="ft14" :title="goal.totalMonthlyGoal">{{ goal.totalMonthlyGoal }}</span>
                                </div>
                            </div>
                            <a-divider style="margin: 16px 0; background-color: rgba(56, 117, 255, 0.3)" />
                            <!-- 子目标 -->
                            <div v-for="sub in goal.monthlyGoalTaskDtoList" :key="sub.id" class="sub-target-box">
                                <div class="sub-header" @click="toggleSubTarget(sub)">
                                    <span
                                        class="arrow-icon"
                                        :class="{ rotated: sub.expanded }"
                                        v-if="sub.storyList && sub.storyList.length > 0"
                                        ><RightOutlined style="font-size: 16px; color: #262626"
                                    /></span>
                                    <span class="sub-name">{{ sub.projectMonthlyGoal }}</span>
                                </div>
                                <div class="sub-desc">
                                    <!--                                    <div-->
                                    <!--                                        v-if="sub.storyList && sub.storyList.length > 0"-->
                                    <!--                                        style="margin-right: 24px"-->
                                    <!--                                    ></div>-->
                                    <!--                                    <div class="ft-label">验收标准：</div>-->
                                    <!--                                    <div class="ft14 space-memory">{{ sub.acceptanceCriteria }}</div>-->
                                    <div style="margin-right: 20px"></div>
                                    <template
                                        v-if="
                                            (sub.taskList && sub.taskList.length) ||
                                            (sub.storyList && sub.storyList.length)
                                        "
                                    >
                                        <!--                    <div class="ft-label" >完成状态：</div>-->
                                        <div class="tags-group-suolv">
                                            <div
                                                class="tag-item"
                                                v-for="(story, index) in sub.taskList"
                                                :title="story.taskStatus"
                                                :style="{ backgroundColor: getStatusColor(story.taskStatus) }"
                                                >{{ index }}</div
                                            >
                                            <div class="tag-item-group" v-for="(story, index) in sub.storyList">
                                                <div
                                                    class="tag-item"
                                                    :title="story.storyStatus"
                                                    :style="{
                                                        backgroundColor: getStatusColor(story.storyStatus)
                                                    }"
                                                ></div>
                                            </div>
                                        </div>
                                    </template>
                                    <div class="ft-label">验收标准：</div>
                                    <div class="ft14 space-memory">{{ sub.acceptanceCriteria || '无' }}</div>
                                </div>

                                <div v-show="sub.expanded" class="story-slot-wrapper">
                                    <div class="story-item" v-for="(story, index) in sub.storyList" :key="story.id">
                                        <div class="story-title">
                                            <div class="title-left">
                                                <div class="version-div">
                                                    <span class="title">版本号 :</span>
                                                    <span class="msg">{{ story.iterationVersionName || '暂无' }}</span>
                                                </div>
                                                <div
                                                    class="priority-tag"
                                                    title="优先级"
                                                    v-if="story.priority"
                                                    style="background-color: getBgc(story.priority)"
                                                    >{{ story.priority }}</div
                                                >
                                                <div
                                                    title="用户故事状态"
                                                    class="status-tag"
                                                    :style="{
                                                        backgroundColor: getStatusColor(story.storyStatus)
                                                    }"
                                                    >{{ story.storyStatus }}</div
                                                >

                                                <div class="story-name" :title="story.storyName">{{
                                                    story.storyName
                                                }}</div>
                                            </div>
                                            <div class="title-right">
                                                <div class="title">任务进度:</div>

                                                <a-tooltip>
                                                    <template #title>
                                                        <div>
                                                            <div>任务总数{{ story.taskNumber }}个</div>
                                                            <div class="flex-color">
                                                                <div class="no-start"></div>
                                                                <div>未开始任务数{{ story.noStartTaskNumber }}个</div>
                                                            </div>
                                                            <div class="flex-color">
                                                                <div class="running"></div>
                                                                <div>进行中任务数{{ story.runningTaskNumber }}个</div>
                                                            </div>
                                                            <div class="flex-color">
                                                                <div class="finish"></div>
                                                                <div>已完成任务数{{ story.finishTaskNumber }}个</div>
                                                            </div>
                                                        </div>
                                                    </template>
                                                    <div style="display: flex; gap: 8px">
                                                        <a-progress
                                                            style="width: 150px; margin-right: 8px"
                                                            :percent="totalPercent(story)"
                                                            :success="{
                                                                percent: finishPercent(story),
                                                                strokeColor: '52c41a'
                                                            }"
                                                            :show-info="false"
                                                            trailColor="#d9d9d9"
                                                            strokeColor="#3875ff"
                                                        />
                                                        <div
                                                            >{{
                                                                formatPercentage(
                                                                    story.taskNumber
                                                                        ? (story.finishTaskNumber / story.taskNumber) *
                                                                              100
                                                                        : 0
                                                                )
                                                            }}%</div
                                                        >
                                                    </div>
                                                </a-tooltip>
                                                <div class="people-icon"></div>
                                                <div class="title">负责人 :</div>
                                                <div class="msg" :title="story.owner">{{ story.owner }}</div>

                                                <div class="time-icon"></div>
                                                <div class="title">计划完成时间 :</div>
                                                <div class="msg no-flex">{{ story.endTime }}</div>
                                                <a-button
                                                    size="small"
                                                    type="link"
                                                    v-permission="'3000001021_vid_b9yp1prrhr'"
                                                    @click="showQuestionMsg(story.description)"
                                                    >查看描述</a-button
                                                >
                                                <a-divider
                                                    v-permission="'3000001021_vid_b9yp1prrhr'"
                                                    type="vertical"
                                                    style="margin: 0; background-color: #3875ff"
                                                />
                                                <a-button
                                                    v-permission="'3000001021_vid_apf0s6w3ri'"
                                                    size="small"
                                                    type="link"
                                                    @click="handleEditStory(story)"
                                                    >编辑</a-button
                                                >
                                                <a-divider
                                                    v-permission="'3000001021_vid_apf0s6w3ri'"
                                                    type="vertical"
                                                    style="margin: 0; background-color: #3875ff"
                                                />
                                                <a-popconfirm
                                                    title="该用户故事关联月度目标，是否确认删除?"
                                                    ok-text="确定"
                                                    cancel-text="取消"
                                                    @confirm="confirmDelete(story.id)"
                                                    @cancel="cancel"
                                                >
                                                    <a-button
                                                        v-permission="'3000001021_vid_sabdi0uugq'"
                                                        size="small"
                                                        type="link"
                                                        >删除</a-button
                                                    >
                                                </a-popconfirm>
                                            </div>
                                        </div>
                                        <div class="content-body">
                                            <div class="story-content">
                                                <div class="item-icon" v-if="story.labels">
                                                    <div
                                                        v-for="(tag, index) in handlerGetSpace(story.labels)"
                                                        class="label-item"
                                                    >
                                                        <div class="label-img"></div>{{ tag }}
                                                    </div>
                                                </div>
                                                <a-descriptions title="" bordered :column="6" size="small">
                                                    <a-descriptions-item label="计划开始">
                                                        <div class="item-content" :title="story.startTime">{{
                                                            story.startTime
                                                        }}</div>
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="实际开始">
                                                        <div class="item-content" :title="story.actualStartTime">{{
                                                            story.actualStartTime
                                                        }}</div>
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="计划完成">
                                                        <div class="item-content" :title="story.endTime">{{
                                                            story.endTime
                                                        }}</div>
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="实际完成">
                                                        <div class="item-content" :title="story.actualEndTime">{{
                                                            story.actualEndTime
                                                        }}</div>
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="任务总数">
                                                        <div
                                                            class="item-content"
                                                            style="color: #3875ff; cursor: pointer"
                                                            :title="story.taskNumber"
                                                            @click="showTaskModal(story.id)"
                                                            >{{ story.taskNumber }}</div
                                                        >
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="进行中任务数">
                                                        <div
                                                            class="item-content"
                                                            style="color: #262626"
                                                            :title="story.runningTaskNumber"
                                                            >{{ story.runningTaskNumber }}</div
                                                        >
                                                    </a-descriptions-item>
                                                    <a-descriptions-item label="备注" :span="5">
                                                        <div class="item-content" :title="story.remark">{{
                                                            story.remarks
                                                        }}</div>
                                                    </a-descriptions-item>
                                                </a-descriptions>
                                                <!-- 第一行 -->
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a-divider style="margin: 16px 0; background-color: rgba(56, 117, 255, 0.3)" />
                        </div>
                    </div>
                </a-spin>
            </div>
            <!-- end vid_v3oimkn2cs 自定义模板_k0p6v9ccmr -->
            <!-- begin vid_g7syhoh0xm 容器_vliufylpso -->
            <al-box v-if="false" class="vid_g7syhoh0xm">
                <!-- begin vid_95rq6cceha 删除 -->
                <a-button v-permission="'3000001092_vid_95rq6cceha'" class="vid_95rq6cceha"> 删除 </a-button>
                <!-- end vid_95rq6cceha 删除 -->
                <!-- begin vid_ldj2jyl9u6 新建 -->
                <a-button v-permission="'3000001092_vid_ldj2jyl9u6'" class="vid_ldj2jyl9u6"> 新建 </a-button>
                <!-- end vid_ldj2jyl9u6 新建 -->
                <!-- begin vid_41qr3p2kzn 编辑 -->
                <a-button v-permission="'3000001092_vid_41qr3p2kzn'" class="vid_41qr3p2kzn"> 编辑 </a-button>
                <!-- end vid_41qr3p2kzn 编辑 -->
                <!-- begin vid_ssz015yzl8 取消展示 -->
                <a-button v-permission="'3000001092_vid_ssz015yzl8'" class="vid_ssz015yzl8"> 取消展示 </a-button>
                <!-- end vid_ssz015yzl8 取消展示 -->
                <!-- begin vid_cdcz5cg9hu 查看甘特图 -->
                <a-button v-permission="'3000001092_vid_cdcz5cg9hu'" class="vid_cdcz5cg9hu"> 查看甘特图 </a-button>
                <!-- end vid_cdcz5cg9hu 查看甘特图 -->
            </al-box>
            <!-- end vid_g7syhoh0xm 容器_vliufylpso -->
        </a-spin>
    </div>
</template>
<script setup lang="tsx">
    import {
        h,
        ref,
        reactive,
        toRaw,
        markRaw,
        watch,
        computed,
        onBeforeMount,
        onMounted,
        onBeforeUnmount,
        onUnmounted,
        onActivated,
        onDeactivated
    } from 'vue'
    import { useRoute, useRouter } from 'vue-router'
    const router = useRouter()
    const route = useRoute()
    import { get, post, put, del, request, requestWithHeaders } from '@/utils/http/Axios'
    import {
        cloneDeep,
        localGet,
        merge,
        getDifferenceArray,
        traversalTreeStructure,
        checkCaseCondition,
        renderStringInTemplate,
        handleBreadcrumbJump,
        throttle,
        permission,
        getComponentParamsValue
    } from '@/utils/index'
    import { isNullOrEmpty, isEmptyArr, isNullOrUnDef, isContained, isArray, isEmpty, isObject } from '@/utils/is'
    import dayjs from 'dayjs'
    import { getPagePcChartsDataSourceConvert } from '@/utils/chart'
    import { message, notification, Modal } from 'ant-design-vue'
    import {
        propertyFormatByNumber,
        propertyFormatByPercentage,
        propertyFormatByDate,
        parseSubFromDataList
    } from '@/utils/format'
    import colorTheme from '@/design/custom-theme.json'
    /*** PUBLISH_EXEGESIS ***
 import UserTableRecords from '@/model/UserTableRecords';
 import { getAppBaseUrl } from '@/utils/index';
 import { sendToken } from "@/hooks/useIframeToken";
 import { useSystemStore } from "@/store/modules/system";
 const systemStore = useSystemStore();
 *** PUBLISH_EXEGESIS ***/

    // 获取传入的流程ID和组件参数
    const props = defineProps({
        'processInstanceId': {
            type: [String, Number, Boolean],
            default: undefined
        },
        'id': {
            type: [String, Number],
            default: undefined
        }
    })
    const immediateWatch = (source, callback) => {
        watch(source, callback, { deep: true, immediate: true })
    }

    /* -------------------------- 属性定义 -------------------------- */

    const setTimeOutList = []
    const pageLoading = reactive({
        loading: false,
        tip: undefined
    })
    const authInfo = localGet('app-user-store')

    // 处理校验
    const setSubFormName = (parentInfo, name) => {
        return [parentInfo.parents, parentInfo.cycleIndex, name]
    }

    /* ========================== 属性定义 ========================== */

    /* -------------------------- 元素数据引用 -------------------------- */

    /* ========================== 元素数据引用 ========================== */

    /* -------------------------- 页面数据 -------------------------- */

    /* ========================== 页面数据 ========================== */

    /* -------------------------- 响应 -------------------------- */

    /* ========================== 响应 ========================== */

    /* -------------------------- 函数 -------------------------- */

    /* ========================== 函数 ========================== */

    /* -------------------------- 页面参数 -------------------------- */

    const pageParameter_state = reactive({
        'processInstanceId': props.processInstanceId ?? route.query.processInstanceId
    })

    /* ========================== 页面参数 ========================== */

    /* -------------------------- 组件事件处理方法 -------------------------- */

    // ---------------------------- 组件数据同步 ----------------------------

    // ============================ 组件数据同步 ============================

    /* ========================== 组件事件处理方法 ========================== */

    /* -------------------------- 生命周期 -------------------------- */
    // 用于参数变更后重新执行自定义指令
    const queryUpdateFlag = ref(0)
    onMounted(() => {})

    onUnmounted(() => {
        // 销毁定时器
        setTimeOutList.forEach(({ repeat, timer }) => {
            repeat ? clearInterval(timer) : clearTimeout(timer)
        })
    })

    /* ========================== 生命周期 ========================== */

    /* -------------------------- 数据关联处理 -------------------------- */

    /* -------------------------- 表单数据同步 -------------------------- */
    /* ========================== 表单数据同步 ========================== */

    /* ========================== 数据关联处理 ========================== */

    /* -------------------------- 不同组件自定义的处理逻辑 -------------------------- */

    /* ========================== 不同组件自定义的处理逻辑 ========================== */

    // ================================定制化逻辑========================================
    onMounted(() => {
        // 初始计算
        updateContentHeight()

        // 监听窗口大小变化
        window.addEventListener('resize', updateContentHeight)

        // 监听 year-goal-content 自身高度变化
        if (goalContentRef.value) {
            resizeObserver = new ResizeObserver(() => {
                updateContentHeight()
            })
            resizeObserver.observe(goalContentRef.value)
        }
    })
    const selectHolder = '请选择'
    const inputHolder = '请输入'
    import { nextTick } from 'vue'
    import Gante from './Page3000001091.vue'
    const useProjectId = ref()
    import { watchEffect } from 'vue'
    import { Quill, QuillEditor } from '@vueup/vue-quill'

    const goalContentRef = ref(null)
    const contentHeight = ref(0)
    // 动态计算高度
    const updateContentHeight = () => {
        const top = goalContentRef.value?.offsetHeight || 0
        contentHeight.value = window.innerHeight - top - 240
    }

    let resizeObserver: ResizeObserver
    const currentYear = dayjs().format('YYYY')
    const currentYearMonth = [`${dayjs().format('YYYY')}-01`, `${dayjs().format('YYYY')}-12`]

    onBeforeUnmount(() => {
        window.removeEventListener('resize', updateContentHeight)
        resizeObserver && resizeObserver.disconnect()
    })
    const targetState = reactive({
        dataSource: [],
        projectList: [],
        parentName: undefined,
        searchForm: {
            month: [],
            year: undefined
        },
        showCheck: false,
        targetLoadog: false,
        addOrEditVisible: false,
        addOrEditTitle: '',
        modalForm: {
            monthlyGoalObjectList: [],
            participantsList: [],
            leaderList: [],
            projectName: undefined,
            projectId: undefined,
            projectType: undefined,
            targetMonth: undefined,
            teamLeaderList: [],
            totalMonthlyGoal: undefined
        },
        allUser: [],
        expendAll: false,
        loading: false,
        ganteVisible: false,
        hiddenVisible: false,
        versionList: [],
        // 范围查看
        showScopeVisible: false,
        scopeLoading: false,
        scopeData: [],
        scopeFilter: {
            year: undefined,
            month: []
        },
        scopeColumns: [],
        // 年度目标
        yearGoal: [],
        yearGoalTitle: '',
        yearGoalModalForm: {
            year: undefined,
            goal: undefined,
            id: undefined
        },
        addOrEditYearGoalVisible: false,
        addOrEditYearGoalLoading: false
    })
    watch(
        () => props.id,
        val => {
            if (props.id) {
                useProjectId.value = props.id
                targetState.searchForm.month = currentYearMonth
                targetState.searchForm.year = currentYear
                targetState.scopeFilter.year = currentYear
                targetState.scopeFilter.month = currentYearMonth
                getParentName()
                getData()
            }
        },
        { immediate: true }
    )

    // 顶部筛选
    /** 切换年份时，清空已选月份区间 */
    const handleYearChange = () => {
        targetState.searchForm.month = [`${targetState.searchForm.year}-01`, `${targetState.searchForm.year}-12`]
        getData()
    }

    /** 禁用不在所选年份的月份 */
    const topSearchDisabledMonth = current => {
        if (!targetState.searchForm.year) {
            return false
        }
        return current.year() !== parseInt(targetState.searchForm.year)
    }

    // 根据id查目录
    const teamLeaderList = ref([])
    function getParentName() {
        targetState.parentName = useProjectId.value
        post('/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/projectNames', {
            projectType: '产品研发'
        }).then(data => {
            let findItem = data.data.projectDtoList.find(item => item.projectId === targetState.parentName)
            if (findItem) {
                teamLeaderList.value = findItem.teamLeaderList
            }
            targetState.modalForm.teamLeaderList = teamLeaderList.value
        })
    }
    function getAllUser() {
        get('/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/allUser').then(data => {
            targetState.allUser = peopleList.value = data.data.userDtoList.map(item => {
                return {
                    label: item.name,
                    value: item.name
                }
            })
        })
    }
    function getData() {
        if (!useProjectId.value) {
            message.info('请选择项目')
            return
        }
        if (!targetState.searchForm.year || !targetState.searchForm.month) {
            return
        }
        targetState.loading = true
        post('/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/monthlyGoals', {
            targetMonthList: targetState.searchForm.month,
            projectId: useProjectId.value
        })
            .then(data => {
                if (data.code !== 200) {
                    message.error(data.message)
                    return
                }
                targetState.dataSource = data.data.monthlyGoalManagementDtoList
            })
            .finally(() => {
                targetState.loading = false
            })
        getYearGoal()
    }
    // 获取年度目标
    function getYearGoal() {
        post('/solution-ppm/api/v2/built-in-system-ppm/pdtm/year_goals', {
            'dateYear': targetState.searchForm.year,
            'projectId': useProjectId.value
        }).then(data => {
            targetState.yearGoal = data.data.dataList
        })
    }
    function resetData() {
        targetState.searchForm = {
            month: currentYearMonth,
            year: currentYear
        }
        getData()
    }
    const formRef = ref(null)
    const targetFormRef = ref(null)
    const targetItem = {
        monthlyGoal: undefined,
        acceptanceCriteria: undefined,
        goalWeight: ''
    }
    function handleAddTargetItem() {
        targetState.modalForm.monthlyGoalObjectList.push({ ...targetItem })
    }
    function handleDeleteTargetItem(index) {
        targetState.modalForm.monthlyGoalObjectList.splice(index, 1)
    }

    function handleAddTarget() {
        if (!useProjectId.value) {
            message.info('请选择项目')
            return
        }
        currentEditData.value = {}
        targetState.addOrEditVisible = true
        targetState.addOrEditTitle = '新建目标'
        getAllUser()
        getParentName()
        targetState.modalForm.monthlyGoalObjectList.push({ ...targetItem })
    }

    const allExpanded = ref(false)

    const toggleSubTarget = sub => {
        sub.expanded = !sub.expanded
    }
    //     展开收起
    const handleExpendAll = () => {
        allExpanded.value = !allExpanded.value
        targetState.dataSource.forEach(goal =>
            goal.monthlyGoalTaskDtoList.forEach(sub => {
                sub.expanded = allExpanded.value
            })
        )
    }
    function handlerGetSpace(data) {
        return data?.split(/[,;；]/)
    }
    const colorMap = {
        '进行中': '#3875FF',
        '完成': '#52C41A',
        '未启动': '#8C8C8C',
        '未开始': '#8C8C8C',
        '已完成': '#52C41A'
    }
    function getStatusColor(status) {
        return colorMap[status] || '#8C8C8C'
    }
    //     用户故事
    const milepostState = reactive({
        searchForm: {
            storyStatus: undefined,
            storyName: undefined,
            directionField: 'created_time-desc',
            labels: undefined
        },
        current: 1,
        addOrEditVisible: false,
        okLoading: false,
        addOrEditTitle: '',
        modalForm: {
            storyName: undefined,
            projetName: undefined,
            priority: undefined,
            labels: undefined,
            timeRangeList: [],
            taskList: [],
            templateTaskId: [],
            monthlyGoalTargetMonth: undefined,
            projectMonthlyGoalManagementId: undefined,
            remarks: undefined
        }
    })
    function cancelStory() {
        currentData.value = {}
        milepostState.addOrEditVisible = false
        milepostState.modalForm = {
            storyName: undefined,
            priority: undefined,
            labels: undefined,
            timeRangeList: [],
            taskList: [],
            templateTaskId: [],
            monthlyGoalTargetMonth: undefined,
            projectMonthlyGoalManagementId: undefined,
            remarks: undefined
        }
        milepostState.current = 1
    }
    const quillEditor = ref(null)
    const currentData = ref({})
    //     编辑story
    function handleEditStory(record) {
        const item = cloneDeep(record)
        Object.assign(milepostState.modalForm, item)
        milepostState.modalForm.timeRangeList = !item.startTime || !item.endTime ? [] : [item.startTime, item.endTime]
        currentData.value = item
        milepostState.addOrEditVisible = true
        milepostState.addOrEditTitle = '编辑用户故事'
        getTarget()
        getAllVersion()
        nextTick(() => {
            let descriptionData = JSON.parse(record.description)
            quillEditor?.value?.setContents(descriptionData)
        })
    }
    function getAllVersion() {
        post('/solution-ppm/api/v2/built-in-system-ppm/iteration_version/list', {
            projectId: useProjectId.value
        }).then(data => {
            targetState.versionList = data.data
                .filter(ver => ver.status === '未发布')
                .map(item => {
                    return {
                        label: item.version,
                        value: item.id,
                        status: item.status // 👈 保留状态
                    }
                })
        })
    }
    // 编辑用户故事查目标
    function getTarget() {
        post('/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/monthlyGoals', {
            targetMonthList: [
                milepostState.modalForm.monthlyGoalTargetMonth,
                milepostState.modalForm.monthlyGoalTargetMonth
            ],
            projectId: useProjectId.value
        }).then(data => {
            if (data.code !== 200) {
                message.error(data.message)
                return
            }
            const allSubGoals = []

            data.data.monthlyGoalManagementDtoList?.forEach(item => {
                item.monthlyGoalTaskDtoList?.forEach(sub => {
                    allSubGoals.push({
                        label: sub.projectMonthlyGoal,
                        value: sub.id
                    })
                })
            })
            milepostState.targetList = allSubGoals
        })
    }
    const showMsgState = reactive({
        visible: false,
        msg: undefined,
        title: ''
    })
    function showQuestionMsg(msg) {
        if (!msg) {
            message.info('暂无描述')
            return
        }
        showMsgState.msg = msg
        showMsgState.visible = true
    }
    function cancelShowMsg() {
        showMsgState.msg = undefined
        showMsgState.visible = false
    }
    //   格式化文本展示
    function getHtmlContent(input) {
        // 防御性处理：避免 null 或 undefined
        if (!input) return ''

        // 尝试解析为富文本 Delta 格式
        let deltaObj = null
        try {
            const parsed = typeof input === 'string' ? JSON.parse(input) : input
            if (parsed?.ops && Array.isArray(parsed.ops)) {
                deltaObj = parsed
            }
        } catch (e) {
            // 解析失败，说明不是 JSON 或不是 Delta 格式，走普通字符串逻辑
        }

        // 如果是富文本格式
        if (deltaObj) {
            try {
                const tempEl = document.createElement('div')
                const quill = new Quill(tempEl)
                quill.setContents(deltaObj)
                return quill.root.innerHTML
            } catch (err) {
                console.error('富文本渲染失败', err)
                return '' // 保险起见返回空
            }
        }

        // 否则是普通文本，做一下换行处理
        return String(input).replace(/\n/g, '<br/>')
    }
    //     富文本设置
    import { nextTick } from 'vue'
    import { QuillEditor, Quill } from '@vueup/vue-quill'
    import ImageUploader from 'quill-image-uploader'
    import '@vueup/vue-quill/dist/vue-quill.snow.css'

    const titleConfig = [
        { Choice: ' .ql-bold', title: '加粗' },
        { Choice: ' .ql-italic', title: '斜体' },
        { Choice: ' .ql-underline', title: '下划线' },
        { Choice: ' .ql-strike', title: '删除线' },
        { Choice: ' .ql-blockquote', title: '块引用' },
        { Choice: ' .ql-code-block', title: '插入代码' },
        { Choice: ' .ql-size', title: '字体大小' },
        { Choice: ' .ql-size', title: '字体大小' },
        { Choice: ' .ql-color', title: '字体颜色' },
        { Choice: ' .ql-background', title: '字体背景颜色' },
        { Choice: ' .ql-list[value="ordered"]', title: '有序列表' },
        { Choice: ' .ql-list[value="bullet"]', title: '无序列表' },
        { Choice: ' .ql-header[value="1"]', title: '1级标题' },
        { Choice: ' .ql-header[value="2"]', title: '2级标题' },
        { Choice: ' .ql-align', title: '对齐方式' },
        { Choice: ' .ql-clean', title: '清除字体格式' },
        { Choice: ' .ql-image', title: '图像' },
        { Choice: ' .ql-size .ql-picker-item[data-value="small"]', title: '小号' },
        { Choice: ' .ql-size .ql-picker-item[data-value="large"]', title: '大号' },
        { Choice: ' .ql-size .ql-picker-item[data-value="huge"]', title: '超大号' },
        { Choice: ' .ql-size .ql-picker-item:nth-child(2)', title: '标准' },
        { Choice: ' .ql-align .ql-picker-item:first-child', title: '居左对齐' },
        { Choice: ' .ql-align .ql-picker-item[data-value="center"]', title: '居中对齐' },
        { Choice: ' .ql-align .ql-picker-item[data-value="right"]', title: '居右对齐' },
        { Choice: ' .ql-align .ql-picker-item[data-value="justify"]', title: '两端对齐' }
    ]
    // 注册图片上传模块
    Quill.register('modules/imageUploader', ImageUploader)

    // 将本地文件转换为URL
    const getLocalImageURL = file => {
        return new Promise(resolve => {
            const reader = new FileReader()
            reader.onload = e => {
                resolve(e.target.result)
            }
            reader.readAsDataURL(file)
        })
    }

    // 表单数据

    // Quill 编辑器选项
    const editorOption = ref({
        modules: {
            // imageUploader: {
            //     upload: async file => {
            //         const localUrl = await getLocalImageURL(file)
            //         return localUrl // 返回本地图片的 URL 进行预览
            //     }
            // },
            toolbar: [
                ['bold', 'italic', 'underline', 'strike'], // 加粗，斜体，下划线，删除线
                ['blockquote', 'code-block'], // 引用，代码块
                [{ header: 1 }, { header: 2 }], // 标题1，标题2
                [{ list: 'ordered' }, { list: 'bullet' }], // 有序列表，无序列表
                [{ size: ['small', false, 'large', 'huge'] }], // 文字大小
                [{ color: [] }, { background: [] }], // 字体颜色，背景颜色
                [{ align: [] }], // 对齐
                ['clean'], // 清除格式
                ['image'] // 链接，图片，视频
            ]
            // ImageUploader: imageHandler
        }
    })
    // 上传API
    const uploadFileAPI = async file => {
        const data = new FormData()
        data.append('file', file)

        return post('/file-storage/api/v1/file/upload', data)
            .then(({ data: { fullUrl } }) => {
                return { data: { fullUrl } }
            })
            .catch(error => {
                console.error('上传图片出错:', error)
                throw error // 抛出错误以供外部处理
            })
    }

    // 将 dataURL 转换为 File 对象的辅助函数
    const dataURLtoFile = (dataurl, filename) => {
        const arr = dataurl.split(',')
        const mime = arr[0].match(/:(.*?);/)[1]
        const bstr = atob(arr[1])
        let n = bstr.length
        const u8arr = new Uint8Array(n)
        while (n--) {
            u8arr[n] = bstr.charCodeAt(n)
        }
        return new File([u8arr], filename, { type: mime })
    }

    function initTitle() {
        document.getElementsByClassName('ql-editor')[0].dataset.placeholder = ''
        for (let item of titleConfig) {
            let tip = document.querySelector('.ql-toolbar' + item.Choice)
            if (!tip) continue
            tip.setAttribute('title', item.title)
        }
    }
    function confirmDelete(id) {
        del(`/solution-ppm/api/v2/built-in-system-ppm/project/story/${id}`).then(data => {
            if (data.code !== 200) {
                message.error(data.message)
                return
            }
            message.success(data.message)
            getData()
        })
    }
    //     用户故事
    //     展示gante
    const gantMonth = ref()
    const gantProjectName = ref()
    function showGante(record) {
        gantMonth.value = record.targetMonth
        gantProjectName.value = record.projectId
        targetState.ganteVisible = true
    }
    function cancelGante() {
        targetState.ganteVisible = false
    }
    //     删除
    const currentHiddenData = ref({})
    // 编辑
    const currentEditData = ref({})
    function handleEditGoal(record) {
        getAllUser()
        get(`/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/monthlyGoals/${record.overallProjectId}`).then(data => {
            currentEditData.value = data.data
            Object.assign(targetState.modalForm, data.data)
            targetState.addOrEditVisible = true
            getLastPeople()
            targetState.addOrEditTitle = '编辑目标'
        })
    }
    function submitTarget() {
        targetFormRef.value.validate().then(() => {
            const url = currentEditData.value.overallProjectId
                ? '/solution-ppm/api/v2/built-in-system-ppm/pmgf/edit/monthlyGoal'
                : '/solution-ppm/api/v2/built-in-system-ppm/pmgf/add/monthlyGoal'
            targetState.targetLoadog = true
            post(url, {
                ...targetState.modalForm,
                projectId: targetState.parentName,
                projectType: '产品研发',
                overallProjectId: currentEditData.value.overallProjectId ? currentEditData.value.overallProjectId : null
            })
                .then(data => {
                    if (data.code !== 200) {
                        message.error(data.message)
                        return
                    }
                    message.success(data.message)
                    cancelTarget()
                    getData()
                })
                .finally(() => {
                    targetState.targetLoadog = false
                })
        })
    }
    function cancelTarget() {
        targetState.addOrEditVisible = false
        targetState.modalForm = {
            monthlyGoalObjectList: [],
            participantsList: [],
            leaderList: [],
            projetName: undefined,
            projectType: undefined,
            targetMonth: undefined,
            teamLeaderList: [],
            totalMonthlyGoal: undefined
        }
        lastPeopleList.value = []
        currentEditData.value = {}
    }
    function confirmHiddenGoal(goal) {
        put(
            `/solution-ppm/api/v2/built-in-system-ppm/pmgf/cancel/relatedStory/${goal.overallProjectId}/${useProjectId.value}`
        ).then(data => {
            if (data.code !== 200) {
                message.error(data.message)
                return
            }
            message.success(data.message)
            getData()
        })
    }
    function confirmDeleteGoal(goal) {
        del(`/solution-ppm/api/v2/built-in-system-ppm/pmgf/delete/monthlyGoals/${goal.overallProjectId}`).then(data => {
            if (data.code !== 200) {
                message.error(data.message)
                return
            }
            message.success(data.message)
            getData()
        })
    }
    // 保存模板项目
    function confirmMbTask() {
        formRef.value.validate().then(async () => {
            milepostState.okLoading = true
            milepostState.modalForm.taskList.forEach(item => {
                item.startTime = item.allTime[0]
                item.endTime = item.allTime[1]
            })
            const deltaContent = quillEditor.value.getContents()

            const imageUploadPromises = []
            deltaContent.ops.forEach(op => {
                if (op.insert && op.insert.image && op.insert.image.startsWith('data:')) {
                    const localSrc = op.insert.image

                    // 如果是 base64 图片，上传并替换为 URL
                    const file = dataURLtoFile(localSrc, 'image.png') // 将 base64 转换为 File 对象

                    const uploadPromise = uploadFileAPI(file).then(({ data: { fullUrl } }) => {
                        // 替换 op 中的 base64 URL 为服务器返回的 URL
                        op.insert.image = fullUrl
                    })

                    imageUploadPromises.push(uploadPromise)
                }
            })

            const api = currentData.value.id ? put : post
            try {
                await Promise.all(imageUploadPromises)
                api(`/solution-ppm/api/v2/built-in-system-ppm/project/story`, {
                    projectId: useProjectId.value,
                    timeRangeList: milepostState.modalForm.timeRangeList,
                    storyName: milepostState.modalForm.storyName,
                    ppmPlatformTaskFormList: milepostState.modalForm.taskList,
                    id: currentData.value.id,
                    priority: milepostState.modalForm.priority,
                    labels: milepostState.modalForm.labels,
                    description: JSON.stringify(deltaContent),
                    monthlyGoalTargetMonth: milepostState.modalForm.monthlyGoalTargetMonth,
                    projectMonthlyGoalManagementId: milepostState.modalForm.projectMonthlyGoalManagementId,
                    remarks: milepostState.modalForm.remarks,
                    iterationVersionId: milepostState.modalForm.iterationVersionId,
                    ownerList: milepostState.modalForm.ownerList
                })
                    .then(data => {
                        if (data.code !== 200) {
                            message.error(data.message)
                            return
                        }
                        message.success(data.message)

                        cancleMbTask()

                        getData()
                    })
                    .finally(() => {
                        milepostState.okLoading = false
                    })
            } catch (error) {
                milepostState.okLoading = false
                console.error('图片上传失败', error)
                return // 终止提交
            }
        })
    }
    // 关闭模板任务新建
    function cancleMbTask() {
        milepostState.addOrEditVisible = false
        milepostState.current = 1
        milepostState.modalForm.functionAbbreviation = undefined
        milepostState.modalForm.templateTaskId = undefined
        milepostState.modalForm = {
            templateTaskId: [],
            projectId: useProjectId.value,
            functionAbbreviation: undefined,
            taskList: []
        }
    }
    // function jumpTask(type, versionId, projectId, storyId) {
    //     return
    //     window.open(
    //         `${
    //             import.meta.env.VITE_PUBLIC_PATH
    //         }/page/3000001150?id=${projectId}&iterationVersionId=&taskStatus=${type}&storyId=${storyId}&jump=true`,
    //         '_blank'
    //     )
    // }
    function showTaskModal(id) {
        taskModalId.value = id
        taskMoadlVisible.value = true
    }
    const taskModalId = ref()
    const taskMoadlVisible = ref(false)
    import TaskJump from './Page3000001214.vue'
    const finishPercent = item => {
        const total = item.taskNumber || 1
        return (item.finishTaskNumber / total) * 100
    }

    const totalPercent = item => {
        const total = item.taskNumber || 1
        return ((item.finishTaskNumber + item.runningTaskNumber) / total) * 100
    }
    const peopleList = ref([])
    function formatPercentage(value) {
        if (value === 0) return '0'
        return value.toFixed(2)
    }
    function handlerAddLastPeople(name) {
        if (targetState.modalForm.participantsList.indexOf(name) !== -1) {
            targetState.modalForm.participantsList = targetState.modalForm.participantsList.filter(
                item => item !== name
            )
        } else {
            targetState.modalForm.participantsList.push(name)
        }
    }
    const lastPeopleList = ref([])
    function getLastPeople() {
        get(`/solution-ppm/api/v2/built-in-system-ppm/platform_product/product_participant/${useProjectId.value}`).then(
            data => {
                if (data.code !== 200) {
                    lastPeopleList.value = []
                    return
                }
                lastPeopleList.value = data.data.map(item => {
                    return {
                        label: item,
                        value: item
                    }
                })
            }
        )
    }
    //     范围查看
    function handleShowScope() {
        getScopeData()
    }
    // 重置范围查看的筛选
    function resetScope() {
        targetState.scopeFilter.year = currentYear
        targetState.scopeFilter.month = currentYearMonth
        getScopeData()
    }
    function getScopeData() {
        if (!targetState.scopeFilter.year || !targetState.scopeFilter.month) {
            return
        }
        targetState.scopeLoading = true
        post('/solution-ppm/api/v2/built-in-system-ppm/pmgf/get/monthlyGoals_pivot', {
            projectId: useProjectId.value,
            targetMonthList: targetState.scopeFilter.month
        })
            .then(data => {
                if (data.code !== 200) {
                    message.error(data.message)
                    targetState.scopeData = []
                    targetState.scopeColumns = []
                    return
                }
                const { columns, rows } = formatTableData(data.data)
                targetState.scopeData = rows
                targetState.scopeColumns = columns
                targetState.showScopeVisible = true
            })
            .finally(() => {
                targetState.scopeLoading = false
            })
    }
    // 格式化
    const formatTableData = res => {
        let rowLabels = res.rowLabels
        const months = res.columns
        const dataMap = res.dataMap

        const rows = Object.keys(rowLabels).map((key, index) => {
            const row: any = { key: index, field: rowLabels[key] }
            months.forEach(m => {
                let value = dataMap[m]?.[key] || ''

                // 如果是子目标，保留成数组，前端再处理
                if (key === 'monthlyGoalTaskDtoList' && Array.isArray(value)) {
                    value = value.map((item, idx) => ({
                        idx: idx + 1,
                        text: item.projectMonthlyGoal || ''
                    }))
                }

                row[m] = value
            })
            return row
        })

        const columns = [
            { title: '字段', dataIndex: 'field', key: 'field', width: 120, align: 'center', fixed: 'left' },
            ...months.map(m => ({
                title: m,
                dataIndex: m,
                key: m,
                width: 400,
                align: 'left'
            }))
        ]

        return { columns, rows }
    }
    //     新建/编辑月度目标
    function showAddOrEditYearGoal() {
        if (targetState.yearGoal.length == 0) {
            targetState.yearGoalTitle = '新建年度目标'
            targetState.yearGoalModalForm.year = targetState.searchForm.year
            targetState.yearGoalModalForm.goal = undefined
        } else {
            targetState.yearGoalTitle = '编辑年度目标'
            targetState.yearGoalModalForm.year = targetState.searchForm.year
            targetState.yearGoalModalForm.id = targetState.yearGoal[0].id
            targetState.yearGoalModalForm.goal = targetState.yearGoal[0].yearGoals
        }
        targetState.addOrEditYearGoalVisible = true
    }
    const yearGoalRef = ref(null)
    function handleSubmitYearGoal() {
        yearGoalRef.value.validate().then(() => {
            targetState.addOrEditYearGoalLoading = true
            put(`/solution-ppm/api/v2/built-in-system-ppm/pdtm/goals`, {
                'projectId': useProjectId.value,
                'yearGoals': targetState.yearGoalModalForm.goal,
                'dateYear': targetState.yearGoalModalForm.year,
                id: targetState.yearGoalModalForm.id
            })
                .then(data => {
                    if (data.code !== 200) {
                        message.error(data.message)
                        return
                    }
                    message.success(data.message)
                    resetYearGoal()
                    getData()
                })
                .finally(() => {
                    targetState.addOrEditYearGoalLoading = false
                })
        })
    }
    function handleDeleteYearGoal() {
        del(`/solution-ppm/api/v2/built-in-system-ppm/pdtm/goals/${targetState.yearGoal[0].id}`).then(data => {
            if (data.code !== 200) {
                message.error(data.message)
                return
            }
            message.success(data.message)
            getData()
        })
    }
    function resetYearGoal() {
        targetState.addOrEditYearGoalVisible = false
        targetState.yearGoalModalForm.year = undefined
        targetState.yearGoalModalForm.goal = targetState.yearGoal[0]?.yearGoals || undefined
        targetState.yearGoalModalForm.id = undefined
    }
    // 范围查看筛选
    /** 切换年份时，清空已选月份区间 */
    const handleScopeYearChange = () => {
        targetState.scopeFilter.month = [`${targetState.scopeFilter.year}-01`, `${targetState.scopeFilter.year}-12`]
        getScopeData()
    }

    /** 禁用不在所选年份的月份 */
    const scopeDisabledMonth = current => {
        if (!targetState.scopeFilter.year) {
            return false
        }
        return current.year() !== parseInt(targetState.scopeFilter.year)
    }
</script>
<style lang="less" scoped>
    .page_root {
        width: 100%;
        height: 100%;
        overflow: auto;
    }
    .page_root :deep(.@{ant-prefix}-spin-nested-loading),
    .page_root :deep(.@{ant-prefix}-spin-container) {
        height: 100%;
    }
    .page_root :deep(.@{ant-prefix}-spin-container .@{ant-prefix}-table-wrapper) {
        display: flex;
        flex-flow: column nowrap;
        justify-content: flex-start;
    }
    .page_root :deep(.@{ant-prefix}-table) {
        flex: auto;
        overflow: auto;
    }
    .table-moreBtn_down {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        width: 100px;
    }

    .table-moreBtn_menu :deep(.table-moreBtn_menu-item):hover {
        background: #ebf1ff;
    }

    /*  表格树结构样式处理，展开按钮层级增加*/
    :deep(.@{ant-prefix}-table-row-expand-icon) {
        z-index: 1;
    }
    /*  表格树结构 由于每个表格项采用自定义组件，使用绝对定位布局，开启树结构导致显示异常，暂时使用层级定位位置 */
    :deep(.@{ant-prefix}-table-row-level-1 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
        left: 15px !important;
        width: calc(100% - 15px);
    }
    :deep(.@{ant-prefix}-table-row-level-2 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
        left: 30px !important;
        width: calc(100% - 30px);
    }
    :deep(.@{ant-prefix}-table-row-level-3 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
        left: 45px !important;
        width: calc(100% - 45px);
    }
    :deep(.@{ant-prefix}-table-row-level-4 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
        left: 60px !important;
        width: calc(100% - 60px);
    }

    /* 穿梭框改变默认样式，为根据组件样式控制左右栏宽度。 */
    :deep(.@{ant-prefix}-transfer-list) {
        height: 100%;
        width: 50%;
    }
    .vid_g7syhoh0xm {
        padding-top: 24px;
        padding-bottom: 24px;
        background-color: #fb0505;
    }
    .vid_ldj2jyl9u6 {
        box-shadow: 0px 0px 0px 0px;
    }
    .vid_ssz015yzl8 {
        box-shadow: 0px 0px 0px 0px;
    }
    .vid_cdcz5cg9hu {
        box-shadow: 0px 0px 0px 0px;
    }

    /*样式*/
    .body {
        overflow: hidden;
        height: 100%;
        position: relative;
        position: relative;
        padding: 4px;
    }
    .top-search {
        border-radius: 4px;
        background-color: #fff;
        margin-bottom: 16px;
    }
    .top-search :deep(.ant3-row) {
        height: 32px;
    }
    .top-search :deep(.ant3-col) {
        height: 32px;
    }
    .content {
        position: relative;
        background-color: #fff;
        border-radius: 4px;

        overflow: auto;
    }
    .top-title {
        display: flex;
        align-items: center;
        padding: 16px 24px;
        padding-top: 0;
        justify-content: space-between;
        background-color: #fff;
    }
    .title-msg {
        padding-left: 8px;
        font-weight: 800;
        font-size: 16px;
        line-height: 16px;
        box-shadow: 0 0;
        border-left-style: solid;
        border-left-width: 4px;
        border-left-color: #3875ff;
    }
    .no-data-image {
        width: 66px;
        height: 80px;
        background-image: url('http://10.40.0.33:9001/file-storage/482099304502618112-source.png');
        background-size: cover;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    .no-date-tip {
        font-size: 14px;
        color: #595959;
        letter-spacing: 0;
        font-weight: 400;
        margin-top: 84px;
    }
    .modal-form :deep(.ant3-form-item-label) {
        width: 100px;
    }
    .reset-btn {
        color: #262626;
        background-color: #eeeeee;
        border-color: #eeeeee;
        border-radius: 4px;
    }
    .reset-btn:hover {
        background: #3875ff;
        border-color: #d9d9d9;
        color: #fff;
    }
    /*目标部分样式*/

    .goal-title-bar {
        height: 40px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 14px;
        background-image: linear-gradient(270deg, rgba(56, 117, 255, 0) 0%, rgba(56, 117, 255, 0.15) 100%);
        box-shadow: inset 4px 0 0 0 #3875ff;
        border-left: 1px solid #3875ff;
        padding-left: 24px;
        .ft16 {
            font-size: 14px;
            color: #262626;
            letter-spacing: 0;
            font-weight: 500;
        }
        .ft14 {
            font-size: 14px;
            color: #262626;
            letter-spacing: 0;
            font-weight: 500;
        }
        .ft-label {
            font-size: 14px;
            color: #595959;
            letter-spacing: 0;
            font-weight: 400;
        }
    }

    .goal-info {
        display: flex;
        gap: 8px;
        align-items: center;
        flex: 1;
        min-width: 0;
    }

    .goal-month {
        color: #1890ff;
        font-weight: 600;
    }

    .goal-product-jf,
    .goal-product-cp,
    .goal-product-sc {
        border-radius: 2px;
        width: 72px;
        height: 22px;
        text-align: center;
        font-size: 14px;
        border: 1px solid;
        letter-spacing: 0;
        line-height: 22px;
        font-weight: 500;
    }
    .goal-product-cp,
    .goal-product-sc {
        background: rgba(179, 127, 235, 0.3);
        color: #722ed1;
        border-color: #b37feb;
    }
    .goal-product-jf {
        width: 44px;
        height: 22px;
        background: rgba(255, 133, 192, 0.3);
        color: #f759ab;
        border-color: #ff85c0;
    }

    .goal-name {
        color: #000;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }
    .goal-ops {
        display: flex;
        gap: 8px;
        align-items: center;
    }
    .approve-img,
    .time-img,
    .xs-img,
    .trd-img,
    .tl-img,
    .fzr-img,
    .zmb-img {
        width: 16px;
        height: 16px;
        background-size: cover;
        flex-shrink: 0;
    }
    .approve-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613185818505216-source.png');
    }
    .time-img {
        margin-left: 8px;
        background-image: url('http://10.40.0.33:9001/file-storage/497178195155970048-source.png');
    }
    .xs-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613331111292928-source.png');
    }
    .trd-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613359385096192-source.png');
    }
    .tl-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613386515951616-source.png');
    }
    .fzr-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613418885492736-source.png');
    }
    .zmb-img {
        background-image: url('http://10.40.0.33:9001/file-storage/517613446855208960-source.png');
    }
    .btn-no-margin {
        padding: 0;
    }
    .first-line,
    .second-line {
        display: flex;
        gap: 24px;
        align-items: center;
        margin-bottom: 8px;
    }
    .line-item {
        display: flex;
        gap: 8px;
        align-items: center;
        min-width: 0; /* 允许.line-item收缩 */
        .ft14 {
            font-size: 14px;
            color: #262626;
            letter-spacing: 0;
            font-weight: 400;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0; /* 允许收缩 */
        }
        .ft-label {
            font-size: 14px;
            color: #595959;
            letter-spacing: 0;
            font-weight: 400;
            flex-shrink: 0; /* 防止标签被压缩 */
        }
    }

    .sub-header {
        display: flex;
        align-items: center;
        justify-content: start;
        cursor: pointer;
        white-space: pre-wrap;
    }

    .arrow-icon {
        font-size: 12px;
        transition: transform 0.2s;
        margin-right: 8px;
        color: #888;
    }

    .arrow-icon.rotated {
        transform: rotate(90deg);
    }

    .sub-name {
        font-size: 14px;
        color: #262626;
        letter-spacing: 0;
        font-weight: 600;
    }

    .sub-desc {
        font-size: 12px;
        color: #979797;
        letter-spacing: 0;
        font-weight: 600;
        display: flex !important;
        padding-bottom: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        padding-top: 8px;
        .ft14 {
            font-size: 12px;
            color: #979797;
            letter-spacing: 0;
            font-weight: 500;
            flex: 1;
        }
        .ft-label {
            font-size: 12px;
            color: #979797;
            letter-spacing: 0;
            font-weight: 400;
        }
    }

    .expand-link {
        color: #1890ff;
        font-size: 14px;
        margin-left: 8px;
        white-space: nowrap;
    }

    .story-slot-wrapper {
        background: #fff;
        border-radius: 4px;
    }
    .story-item {
        box-shadow: 0 2px 5px 0 #c9dfff;
        border-radius: 0px;
        margin-bottom: 20px;
        .btn-opration {
            background-color: #ebf1ff;
            color: #3875ff;
        }
        :deep(.ant3-descriptions-view) {
            table {
                table-layout: fixed !important; /* 固定表格布局 */
                width: 100% !important;
                color: red;
            }
        }
        :deep(.ant3-descriptions-view) {
            table {
                table-layout: fixed !important; /* 固定表格布局 */
                width: 100% !important;
                color: red;
            }
        }
        :deep(.ant3-descriptions-bordered.ant3-descriptions-small .ant3-descriptions-item-label) {
            padding: 8px 8px;
        }
        :deep(.ant3-descriptions-bordered.ant3-descriptions-small .ant3-descriptions-item-content) {
            padding: 8px 8px;
        }
        .time-icon,
        .people-icon,
        .jz-icon {
            width: 16px;
            height: 16px;
            background-size: cover;
        }
        .time-icon {
            background-image: url('http://10.40.0.33:9001/file-storage/497178195155970048-source.png');
        }
        .people-icon {
            background-image: url('http://10.40.0.33:9001/file-storage/497178207099250688-source.png');
        }
        .story-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            flex: 1;
            min-width: 0; /* 必须设置 */
        }

        .story-title {
            width: 100%;
            display: flex;
            justify-content: space-between;
            background-image: linear-gradient(270deg, rgba(105, 173, 255, 0.05) 0%, rgba(56, 117, 255, 0.1) 100%);
            border-radius: 0;
            padding: 9px 24px;
            gap: 16px;
            align-items: center;
            left: 0;
        }
        .title-left {
            display: flex;
            gap: 8px;
            font-size: 16px;
            color: #262626;
            letter-spacing: 0;
            font-weight: 600;
            align-items: center;
            width: 40%;
            flex-shrink: 0;
            min-width: 0; /* 防止子元素撑破父容器 */
        }
        .title-right {
            display: flex;
            gap: 4px;
            align-items: center;
            min-width: 0; /* ⭐ 关键：允许压缩，触发省略 */
            flex: 1; /* 自适应剩余空间 */
            justify-content: end;
            .title,
            .people-icon,
            .time-icon {
                flex-shrink: 0;
            }
            .no-flex {
                flex-shrink: 0;
            }
            .msg {
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
        }
        .status-tag,
        .priority-tag {
            font-size: 14px;
            color: #ffffff;
            letter-spacing: 0;
            text-align: center;
            line-height: 22px;
            padding: 0 4px;
            font-weight: 500;
            min-width: 32px;
            height: 22px;
            border-radius: 0;
            text-align: center;
        }
        .priority-tag {
            background: #40a9ff;
            border-radius: 0px;
            font-style: oblique;
        }
        .content-body {
        }
        .story-content {
            padding: 10px;
        }
        .item-title {
            white-space: nowrap;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #595959;
            letter-spacing: 0;
            text-align: right;
            font-weight: 400;
        }

        .item-content {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            cursor: default;
            font-family: PingFangSC-Medium;
            font-size: 14px;
            color: #262626;
            letter-spacing: 0;
            font-weight: 600;
        }
        .item-icon {
            display: flex;
            flex-wrap: wrap;
            gap: 8px; /* 可选：让 tag 之间有间距 */
            margin: 16px 0;
        }
        .label-item {
            display: flex;
            background-color: #eeeeee;
            align-items: center;
            padding: 1px 8px;
            font-size: 14px;
            color: #595959;
            letter-spacing: 0;
            text-align: center;
            font-weight: 400;
            gap: 4px;
            border-radius: 0px;
        }
        .label-img {
            background-image: url('http://10.40.0.33:9001/file-storage/503656902913648640-source.png');
            background-size: cover;
            width: 10px;
            height: 10px;
        }
        .target-item {
            align-items: center;
        }
    }
    .form-model :deep(.ant3-form-item-label) {
        width: 110px;
    }
    /*目标部分样式*/
    .space-memory {
        white-space: break-spaces;
    }
    .version-div {
        font-size: 14px;
    }
    .flex-color {
        display: flex;
        gap: 4px;
        align-items: center;
    }
    .no-start,
    .running,
    .finish {
        width: 10px;
        height: 10px;
        border-radius: 50%;
    }
    .no-start {
        background-color: #d9d9d9;
    }
    .running {
        background-color: #3875ff;
    }
    .finish {
        background-color: #52c41a;
    }
    .tags-group-suolv {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        margin-right: 14px;
        padding-right: 14px;
        border-right: 1px solid #dcdfe6;
        height: 12px;
        gap: 1px;
        .tag-item-group {
            display: flex;
        }
        .tag-item {
            min-width: 10px;
            width: 10px;
            height: 8px;
            font-size: 0;
            &.tag-item-b {
                width: 2px;
            }
        }
    }
    .year-goal-title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 12px;
        .year-font {
            height: 16px;
            font-size: 16px;
            padding-left: 8px;
            border-left: 4px solid #3875ff;
            line-height: 16px;
            font-weight: 600;
        }
        .label {
            color: #595959;
        }
        .value {
            color: #262626;
        }
    }
    .year-goal-content {
        padding: 12px 20px;
        box-shadow: 0 0 10px #e5e5e5;
        margin-bottom: 16px;
    }
    .desc-value {
        display: -webkit-box; /* 必须 */
        -webkit-box-orient: vertical; /* 必须 */
        -webkit-line-clamp: 3; /* 限制3行 */

        max-width: fit-content; /* 宽度随内容撑开 */
        max-height: 120px; /* 可选，和line-clamp保持一致 */

        overflow: hidden; /* 必须 */
        text-overflow: ellipsis; /* 必须 */

        white-space: pre-wrap; /* 保留换行符 */
        word-break: break-word; /* 自动换行 */
        cursor: pointer;
    }

    .table-box :deep(.@{ant-prefix}-table-tbody) tr > td {
        font-size: 14px;
        font-weight: 400;
        color: #262626;
        border-bottom: 1px solid #d9d9d9;
        padding: 8px 16px;
        word-break: break-all;
    }
</style>
